package com.qf.boot2202day02.controller;

import com.baomidou.kaptcha.Kaptcha;
import com.sun.org.apache.bcel.internal.classfile.Code;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/kapchar")
public class KapcharController {

    @Autowired
    Kaptcha kaptcha;

    @GetMapping("/render")
    public void getcapchar(){
        kaptcha.render();
    }


    @GetMapping("/valid/{code}")
    public void validate(@PathVariable("code") String code){
        final boolean validate = kaptcha.validate(code);
        System.out.println(validate);
    }


    @GetMapping("/validtime/{code}")
    public void validtime(@PathVariable("code") String code){
        final boolean validate = kaptcha.validate(code, 20);
        System.out.println(validate);
    }

}
